<template>
	<view class="container" :class="'theme-'+theme">
				<image class="top-back" src="../../static/top-back.png" v-show="showToTop" @click="toTop()"></image>

		<view class="content">
			<view class="head-section">
				<view class="" style="margin: 10rpx;">
					<u-icon name="arrow-left" size='25px' color='#eeeeee' @click="returnIndex"></u-icon>
				</view>
				<view class="wuliu">
					<view class="contentBox"></view>

					<view class="contentBoxCenter" >
						<!-- <u-icon :name="(orderCancelLog.remark||orderFailLog.remark)?'close-circle-fill':'checkmark-circle-fill'" style='margin-right:10rpx;'></u-icon> -->
						<text style="line-height: 80rpx;text-align: center;">{{cancelApplyInfo.curStatus==1 ? '取消待确认':statusData[order.status]}}</text>
					</view>

					<!-- <view class="contentBox" v-if="!(orderCancelLog.remark||orderFailLog.remark)">
						<u-icon name="more-circle-fill" style='margin-right:10rpx;'></u-icon>
						<text style="line-height: 80rpx;text-align: center;">待收货</text>
					</view> -->
					<!-- <view v-if="false" class="contentBox">
						<u-icon name="checkmark-circle-fill" style='margin-right:10rpx;'></u-icon>
						<text style="line-height: 80rpx;text-align: center;">已完成</text>
					</view> -->
					<!-- <view v-if="orderCancelLog.remark" class="contentBox">
						<u-icon name="close-circle-fill" style='margin-right:10rpx;'></u-icon>
						<text style="line-height: 80rpx;text-align: center;">已取消</text>
					</view>
					<view v-if="orderFailLog.remark" class="contentBox">
						<u-icon name="close-circle-fill" style='margin-right:10rpx;'></u-icon>
						<text style="line-height: 80rpx;text-align: center;">提交失败</text>
					</view> -->
					<!-- 查看原因按钮 -->
					<view style="margin-right:30rpx;justify-content: flex-end;" class="contentBox">
						<view class="reasonButton" @click="showReason()" v-if="orderCancelLog.remark||orderFailLog.remark" >
							查看原因
						</view>
					</view>
				</view>
				<view class="cgr-info" style="margin: 0 auto;">

						<text class="eticon eticon-dingwei themeTextColor cgr-icon"></text>
					<!-- <u-icon name="map"></u-icon> -->
<!-- 					<view class="">
						<image src="../../static/newh5/address.png" class="yticon" style="width: 16px;height: 20px;margin-top: 10rpx;">
						</image>
					</view> -->
					<view class="">
						<text>{{order.consigneeName}}</text>
						<text class="tel">{{order.mobile}}</text>
						<view class="address">
							<text>{{ (order.area? order.area : '') +' '+ order.ext.addr ? order.ext.addr : ''}}</text>
						</view>
					</view>

				</view>
			</view>
			<uni-popup ref="showReason"  :mask-click="false">
				<view class="uni-tip">
					<text class="uni-tip-title">{{reasonShow}}</text>
					<view class="popup-content uni-tip-content">
						<view class="order-info">{{orderCancelLog.remark}}</view>
						<view class="order-info">{{orderFailLog.remark}}</view>
						</view>
					<view class="uni-tip-group-button">
						<!-- <text class="uni-tip-button" @click="close('cancel')">取消</text> -->
						<text class="uni-tip-button confirm" @click="cancelReason()">确定</text>
					</view>
				</view>
			</uni-popup>

			<view v-if="cancelApplyInfo.curStatus==1&&countDown>0" style="text-align: center;padding-top: 10rpx;">
				<view style="background-color: #fef1e0;border-radius: 8rpx;margin: 0 auto;padding: 8rpx 40rpx;width: fit-content;">
					<view>剩余确认时间</view>
					<u-count-down bgColor="#fef1e0" :timestamp="countDown"></u-count-down>
				</view>
				<view style="color: #909090;margin: 10rpx 0;">供应商若逾期未确认，系统将自动退款给您</view>
			</view>
			<view class="line" @click="showSupplier">
				<text class="eticon eticon-gongyingshang themeTextColor" style="margin-left: 0;margin-right: 16rpx;font-size: 20px;"></text>
				<!-- <image src="../../static/newh5/supply.png" class="yticon" style="width: 20px;height: 20px;"></image> -->
				<text style="flex: 1;">供应商：{{order.supplierName}}</text>
				<u-image style="margin-left: 10rpx;" v-if="order.protocolType=='eplus'&&order.productLogo!=''" :src="order.productLogo"
					width="100rpx" height="50rpx"></u-image>
				<text style="color: #909399;margin: 0 10rpx;">联系供应商</text>
				<text style="color: #909399;font-size: 28rpx;margin-right: 0;" class="yticon icon-you"></text>
			</view>
			<view class="product-list">
				<!-- class="item"  -->
				<view class="item"
				v-for="(item,index) in order.items" :key="index"
				@click="goProductDetail(item.productId)"
				v-show="index<3?true:canHide">
					<view class="left">
						<image :src="item.thumbnail"></image>
					</view>
					<view class="right">
						<view class="name">
							<text>{{item.productName}}</text>
						</view>
						<view class="bottom">
							<view class="price">
								<text class="wordClass">￥{{item.salePrice|money}}</text>
							</view>
							<view class="num">
								<text class="wordClass">&#10005; {{item.num}} {{item.unit}}</text>
							</view>
						</view>
<!--						<view style="width: 100%;margin-top: 14rpx;">
							<view class="action" v-if="order.status==='completed'"  @click.stop="clickAfterSale(item)">
								申请售后</view>
						</view>-->
					</view>
				</view>
				<view class="showHide" @click="isShowGood()" v-show="!canHide&&order.items.length>3">
					<view>
						<text>共有{{order.items.length}}件商品，</text>
						<text>点击展开更多</text>
						<u-icon name="arrow-down" style="color: #909090;"></u-icon>
					</view>
				</view>
				<view class="showHide" @click="isShowGood()" v-show="canHide">
					<view>
						<text>收起</text>
						<u-icon name="arrow-up" style="color: #909090;"></u-icon>
					</view>
				</view>
			</view>
			<view class="total">
				<view class="total-l">
					<text class="l-word">商品总额</text>
					<text class="l-p wordClass">￥{{order.originalPriceTotal|twoBitMoney}}</text>
				</view>
				<view class="total-l">
					<text class="l-word">运费总计</text>
					<text class="l-p wordClass">￥{{summary.freight|twoBitMoney}}</text>
				</view>
				<view v-if="order.ext.confService" class="total-l">
					<text class="l-word">服务费</text>
					<text class="l-p wordClass">￥{{order.serviceFee|twoBitMoney}}</text>
				</view>
				<view v-if="order.ext.confService" class="total-l">
					<text class="l-word">优惠金额</text>
					<text class="l-p wordClass">-￥{{order.preferentialFee|twoBitMoney}}</text>
				</view>
				<view class="total-l">
					<text class="l-word">共优惠</text>
					<text class="l-p wordClass" style="color: red;">￥{{supplierDiscountTotal|twoBitMoney}}</text>
				</view>
				<view class="total-l" @click="clickShowDiscount">
					<text class="l-word">店铺优惠</text>
					<text class="l-p wordClass" style="color: red;">￥{{supplierDiscountTotal|twoBitMoney}}</text>
					<u-icon v-if="supplierDiscountTotal>0" style="transform: scaleX(.8);" name="arrow-down"></u-icon>
				</view>
				<view v-show="showDiscount" style="background-color: #f5f5f5;padding: 20rpx;margin: 20rpx 0;border-radius: 10rpx;">
					<view style="font-size: 24rpx;margin-top: 10rpx;" v-for="(discount,index) in discountList"
						:class="{'supplier':index>0&&index<discountList.length}" :key="index">
						<scroll-view scroll-x>
							<view style="display: flex;align-items: center;">
								<view v-for="product in discount.goodsList" :key="product.id"
									style="margin-right: 10rpx;text-align: center;">
									<image mode="widthFix" :src="product.thumbnail" style="width: 90rpx;height: 90rpx;" />
									<view style="color: #ff7200;">优惠¥{{getDiscount(product)|twoBitMoney}}</view>
								</view>
							</view>
						</scroll-view>
						<view style="margin-top: 10rpx;">
							<text style="color: #ff7200;margin-right: 10rpx;">{{discount.activity.name}}</text>
							<text style="color: #909090;">
								{{discount.activity.activityStartTime}} ~ {{discount.activity.activityEndTime}}
							</text>
						</view>
						<view style="margin-top: 10rpx;">
							<u-tag size="mini" :text="discount.rule" mode="plain" type="error" />
							<text style="color: #ff7200;margin-left: 10rpx;">
								小计：¥{{discount.total|twoBitMoney}} 优惠：¥{{discount.discount|twoBitMoney}}
							</text>
						</view>
					</view>
				</view>
				<view class="total-l">
					<text class="l-word">订单总额</text>
					<text class="l-p wordClass" style="color: red;">￥{{order.amount|twoBitMoney}}</text>
				</view>
				<!-- <view class="time">
					<text>下单时间：{{order.createTime}}</text>
				</view> -->
			</view>
			<!-- order.invoiceMethod ==2 不开发票类型？  -->
			<view class="total" v-if="order.invoiceMethod == 1">
				<view class="invoiceBox">
					<view class="title">
						<view class="">
							<text class="wordClass" style="font-size: 15px;"> 发票信息</text>
						</view>
						<view class="" @click="isBillShow()" v-show="!billShow">
							<text class="wordClass l-word" style="color: #909090;margin-right: 4rpx;">查看更多</text>
							<u-icon name="arrow-down" style="color: #909090;"></u-icon>
						</view>
					</view>
					<view class="total-l">
						<text class="l-word">发票类型</text>
						<text class="wordClass" style="margin-left: 50rpx;">{{order.invoiceType=='general'?'增值税普通发票':'增值税专用发票' }}</text>
					</view>
					<view class="total-l">
						<text class="l-word">发票抬头</text>
						<text class="wordClass" style="margin-left: 50rpx;">{{order.invoiceTitle }}</text>
					</view>
					<view class="total-l">
						<text class="l-word">纳税识别号</text>
						<text class="wordClass" style="margin-left: 50rpx;">{{order.ext.invoiceTaxCode }}</text>
					</view>
					<!-- <view class="total-l" v-show="billShow">
						<text class="l-word">纳税识别号2</text>
						<text class="wordClass" style="margin-left: 50rpx;">91130400105670924W</text>
					</view> -->
					<view class="total-l" v-show="billShow">
						<text class="l-word">注册地址</text>
						<text class="wordClass" style="margin-left: 50rpx;">{{order.ext.invoiceAddress}}</text>
					</view>
					<view class="total-l" v-show="billShow">
						<text class="l-word">注册电话</text>
						<text class="wordClass" style="margin-left: 50rpx;">{{order.ext.invoicePhone}}</text>
					</view>
					<view class="total-l" v-show="billShow">
						<text class="l-word">开户银行</text>
						<text class="wordClass" style="margin-left: 50rpx;">{{order.ext.invoiceBank}}</text>
					</view>
					<view class="total-l" v-show="billShow">
						<text class="l-word">银行账号</text>
						<text class="wordClass" style="margin-left: 50rpx;">{{order.ext.invoiceBankAccount}}</text>
					</view>
					<view class="hideButton"  v-show="billShow" @click="isBillShow()">
						<view class="innerBox">
							<text style="margin-right: 4rpx;">收起</text>
							<u-icon name="arrow-up" size="20"></u-icon>
						</view>
					</view>
				</view>
			</view>
			<!-- 订单信息 -->
			<view class="total">
				<view class="invoiceBox">
					<view class="title">
						<view class="">
							<text class="wordClass" style="font-size: 15px;"> 订单信息</text>
						</view>
						<view class="" v-show="!orderShow">
							<text class="wordClass l-word" style="color: #909090;margin-right: 4rpx;"  @click="isOrderShow">查看更多</text>
							<u-icon name="arrow-down" style="color: #909090;"></u-icon>
						</view>
					</view>
					<view class="total-l">
						<text class="l-word" >订单编号<text class="wordClass" style="margin-left: 50rpx;" >{{order.sn}}</text></text>
						<copyButton :content="order.sn"></copyButton>
					</view>
					<view class="total-l">
						<text class="l-word">下单时间</text>
						<text class="wordClass" style="margin-left: 50rpx;">{{order.createTime}}</text>
					</view>
					<view class="total-l">
						<text class="l-word">供应商订单号</text>
						<text class="wordClass" style="margin-left: 50rpx;">{{order.thirdSn}}</text>
						<copyButton :content="order.thirdSn"></copyButton>
					</view>
					<view v-if="isGzyhUser">
						<view class="total-l" v-show="orderShow">
							<text class="l-word">BPM系统审批号</text>
							<text class="wordClass" style="margin-left: 50rpx;">{{order.ext.bpmAuditNo||'无'}}</text>
							<copyButton v-if="order.ext.bpmAuditNo" :content="order.ext.bpmAuditNo"></copyButton>
						</view>
					</view>
					<view class="total-l" v-show="orderShow">
						<text class="l-word">采购人</text>
						<text class="wordClass" style="margin-left: 50rpx;">{{order.master.userName}}</text>
						<!-- <copyButton :content="order.sn"></copyButton> -->
					</view>
					<view class="total-l" v-show="orderShow">
						<text class="l-word">联系电话</text>
						<text class="wordClass" style="margin-left: 50rpx;">{{order.master.userMobile}}</text>
						<!-- <copyButton :content="order.sn"></copyButton> -->
					</view>
					<view class="total-l" v-show="orderShow">
						<text class="l-word">采购部门</text>
						<text class="wordClass" style="margin-left: 50rpx;">{{order.master.deptName}}</text>
						<!-- <copyButton :content="order.sn"></copyButton> -->
					</view>
					<view class="hideButton"  v-show="orderShow" @click="isOrderShow()">
						<view class="innerBox">
							<text style="margin-right: 4rpx;">收起</text>
							<u-icon name="arrow-up" size="20"></u-icon>
						</view>
					</view>
				</view>
			</view>

      <!-- 操作信息 -->
      <view class="total" v-if="logData.length > 0">
        <view class="invoiceBox">
          <view class="title">
            <view class="">
              <text class="wordClass" style="font-size: 15px;"> 操作信息</text>
            </view>
          </view>
          <view>
            <u-table class="MT10">
              <u-tr class="u-tr">
                <u-th class="u-th" width="80rpx">序号</u-th>
                <u-th class="u-th" width="200rpx">操作项</u-th>
                <u-th class="u-th" width="200rpx">操作人</u-th>
                <u-th class="u-th" width="200rpx">操作时间</u-th>
              </u-tr>
              <u-tr class="u-tr" v-for="(item,i) in logData">
                <u-td class="u-td" width="80rpx">{{ i+1 }}</u-td>
                <u-td class="u-td" width="200rpx">{{ item.logMsg }}</u-td>
                <u-td class="u-td" width="200rpx">{{ item.optName }}</u-td>
                <u-td class="u-td" width="200rpx">{{ item.createTime }}</u-td>
              </u-tr>
            </u-table>
          </view>
        </view>
      </view>
			<view class="total" v-if="logisticsList.length>0">
				<view class="invoiceBox">
					<view class="title">
						<view class="">
							<text class="wordClass" style="font-size: 15px;"> 物流信息</text>
						</view>
					</view>
					<u-tabs-swiper :show-bar="true" font-size="26" :active-color="themeColor" ref="tabs"
					               :list="logisticsTab" :current="current" @change="onTabsChange"
					               :is-scroll="false"></u-tabs-swiper>
					  <swiper :current="logTabIndex" style="height: 500rpx;" class="swiper-area" duration="300" @change="changeLogTab">
					    <swiper-item class="s-item" style="display: flex;flex-direction: column;" v-for="(item,index) in logisticsList" :key="index">
					      <view class="c-line" style="line-height: 40rpx;" v-if="item.isSupplierSplit">供应商子订单号：{{item.emallSn}}</view>
					      <view class="c-line" style="line-height: 40rpx;">发货方式：{{dictData[item.deliveryType]}}</view>
					      <view class="c-line" style="line-height: 40rpx;">发货商品：
					        <text v-for="(product,pIndex) in item.detailList" :key="pIndex">{{product.orderItem.productName}} x {{product.num}}<text v-if="pIndex<item.detailList.length-1">、</text></text>
					      </view>
					      <view class="c-line" style="line-height: 40rpx;" v-if="item.deliveryType==='1'">物流公司：{{item.name}}</view>
					      <view class="c-line" v-if="item.deliveryType==='1'">物流单号：{{item.sn}}
							<copyButton style='display: inline-flex;font-size: 13px;line-height: normal;' :content="item.sn"></copyButton>
						  </view>
					      <view class="p-line" style="display: flex;align-items: flex-start;margin-top: 4rpx;flex: 1;height: 0;" v-if="item.deliveryType==='1'&&item.trackList&&item.trackList.length>0">
					        <view>物流详情：</view>
					        <view style="flex: 1;overflow-y: auto;height: 100%;">
							  <m-steps v-for="(track, tIndex) in item.trackList" :item='track' :key="tIndex" :index='tIndex' :activity="0" date='operateTime'>
							  </m-steps>
					        </view>
					      </view>
					      <u-button v-if="!item.isConfirmReceipt" :custom-style="buttonStyle" size="mini" :ripple="true" shape="circle" @click="clickConfirm(item)">确认收货</u-button>
					    </swiper-item>
					  </swiper>
				</view>
			</view>
			<!-- 预算信息 -->
			<template v-if="budgetList.length > 0">
				<view class="total" v-for="(budget,index) in budgetList" :key="budget.id">
					<view class="invoiceBox">
						<view class="title">
							<view class="">
								<text class="wordClass" style="font-size: 15px;"> 预算信息</text>
							</view>
							<view class="" v-if="!budgetShow[index]">
								<text class="wordClass l-word" style="color: #909090;margin-right: 4rpx;"  @click="isBudgetShow(index)">查看更多</text>
								<u-icon name="arrow-down" style="color: #909090;"></u-icon>
							</view>
						</view>
						<view class="total-l">
							<text class="l-word" >预算编号<text class="wordClass" style="margin-left: 50rpx;" >{{budget.budgetCode}}</text></text>
							<copyButton :content="budget.budgetCode"></copyButton>
						</view>
						<view class="total-l">
							<text class="l-word">预算名称</text>
							<text class="wordClass" style="margin-left: 50rpx;">{{budget.budgetName}}</text>
						</view>
						<view class="total-l">
							<text class="l-word">可用金额</text>
							<text class="wordClass" style="margin-left: 50rpx;">{{budget.budgetBalance}}</text>
						</view>
						<template v-if="budgetShow[index]">
							<view class="total-l">
								<text class="l-word">本次使用金额</text>
								<text class="wordClass" style="margin-left: 50rpx;">{{budget.amount}}</text>
								<!-- <copyButton :content="order.sn"></copyButton> -->
							</view>
							<view class="total-l">
								<text class="l-word">剩余数量</text>
								<text class="wordClass" style="margin-left: 50rpx;">{{budget.budgetNum}}</text>
								<!-- <copyButton :content="order.sn"></copyButton> -->
							</view>
							<view class="total-l">
								<text class="l-word">本次使用数量</text>
								<text class="wordClass" style="margin-left: 50rpx;">{{budget.num}}</text>
								<!-- <copyButton :content="order.sn"></copyButton> -->
							</view>
							<view class="total-l">
								<text class="l-word">采购目录</text>
								<text class="wordClass" style="margin-left: 50rpx;">{{budget.budgetCatalogName}}</text>
								<!-- <copyButton :content="order.sn"></copyButton> -->
							</view>
							<view class="hideButton" @click="isBudgetShow(index)">
								<view class="innerBox">
									<text style="margin-right: 4rpx;">收起</text>
									<u-icon name="arrow-up" size="20"></u-icon>
								</view>
							</view>
						</template>
					</view>
				</view>
			</template>
			<view class="plusBuy" v-if="enableOneMoreOrder">
				<view class="plusButton themeBorderColor themeTextColor" v-if="enableOneMoreOrder"  @click="addToCart()">
					<text class="buttonWord themeTextColor">再来一单</text>
				</view>
				<!-- <view class="primaryButton" @click="goDetailWuLiu()" v-if="logisticsList.length>0">
					<text class="buttonWord">查看物流</text>
				</view> -->
				<!-- <view class="primaryButton themeBorderColor themeTextColor" v-if="order.status === 'shipped'||order.status==='partialShipment'" @click="beforeConfirm(order)">
					<text class="buttonWord themeTextColor">确认收货</text>
				</view> -->
			</view>
		</view>
	<online-service v-if="isShowCustomerService" is-platform></online-service>
	<!-- <order-track :show="receivePopupShow" :logisticsList="logisticsList" :logisticsTab="logisticsTab" @confirm="clickConfirm(item)" :dictData="dictData"></order-track> -->
	<u-popup v-model="supplierShow" mode="bottom" height="40%" border-radius="20" closeable>
		<view style="padding: 30rpx;">
			<view style="color: black;font-size: 34rpx;text-align: center;font-weight: bold;">供应商联系方式</view>
			<view style="display: flex;align-items: center;padding: 40rpx;">
				<text style="width: 30%;">{{supplierData.supplierContact}}</text>
				<text class="yticon" style="margin: 0 10rpx;text-decoration: none;" @click="makePhoneCall(supplierData.supplierContactPhone)">
				  <uni-icons type="phone" size="18"></uni-icons>
				</text>
				<text style="flex: 1;">{{supplierData.supplierContactPhone}}</text>
				<online-service v-if="supplierCustomerGroup[supplierData.id]" @service="toOnlineService()"></online-service>
			</view>
		</view>
	</u-popup>
	</view>
</template>

<script>
	import moment from 'moment'
	import mSteps from '@/components/m-steps/m-steps.vue'
	import OnlineService from '../../components/online-service/online-service.vue'
	import OrderTrack from '../../components/order-track/order-track.vue'
	import {  goback } from "@/common/utils/navigateBack.js";
	import { qryConfByItemCode } from "@/api/user/user.js";
	import copyButton from '../../components/copy.vue'
	import uniCollapse from '../../components/uni-collapse/uni-collapse.vue'
	import uniCollapseItem from '../../components/uni-collapse-item/uni-collapse-item.vue'
	import {
		getOrderDetail,
		getLogistics,
		getOrderLogs,
		queryOrderLogsInfo
	} from '@/api/order/detail.js';
	import {
		getDict,
		confirmReceipt,
		getAllStatus,
		applyAftersale,
		buyAgain,
    getLogList
	} from '../../api/order/order.js'
	import { getBudgets } from "@/api/backlog/backlog.js"
	import { onlineService } from '../../api/index';
	import {listCustomerGroupBySupplierId} from '@/api/user/user.js'
	export default {
		components: {
			uniCollapse,
			uniCollapseItem,
			copyButton,
			OrderTrack,
			mSteps
		},
		data() {
			return {
				countDown:0,
				// 取消订单申请信息
				cancelApplyInfo: {
				  curStatus: '0', // 0-无申请信息，1-在申请中，2-已申请通过，3-已申请被拒绝
				  applyTime: '', // 最近一次申请时间，若curStatus=1/2/3时。
				  auditTime: '', // 最近一次申请审核时间，若curStatus=2/3时。
				  rejectReason: '', // 最近一次申请审核拒绝原因，若curStatus=3时。
				},
				showDiscount:false,
				// 优惠信息 多个维度 包括多件折扣/n件任选等
				discountList:[],
				// 店铺优惠金额
				supplierDiscountTotal:0,
				buttonStyle:{
					plain:true,
				position: 'sticky',
				right: 0,
				marginRight:0,
				bottom: 0,
				float:'right'
        	},
				logTabIndex:0,
				current:0,
				receivePopupShow:false,
				canHide:false,
				//控制发票的查看更多
				billShow:false,
				orderShow:false,
				budgetShow: [],
				turnId:'',
				order: {
					ext: {},
					items: {},
					master: {}
				},
				summary: {
					num: 0,
					totalPrice: 0,
					freight: 0,
					amount: 0,
					amountDesc: 0
				},
				statusData: {},
				dictData: {},
				id: '',
				orderCancelLog: {},
				orderFailLog: {},
				budgetList: [],
				logisticsList:[],
				logisticsTab:[],
				// 是否广州银行用户
				isGzyhUser:false,
				// 再来一单
								showToTop: false,
								listScrollTop:0,
				enableOneMoreOrder:false,
				// 是否显示平台客服
				isShowCustomerService:0,
				supplierShow:false,
				supplierData:{},
				supplierCustomerGroup:{},
        logData: []
			}
		},
		onReady() {
			this.buttonStyle.border = this.themeColor
			this.buttonStyle.color = this.themeColor
		},
		onLoad(op) {
			// 初始化是否显示客服
			this.isShowCustomerService = uni.getStorageSync('isShowCustomerService')
			  ? Number(uni.getStorageSync('isShowCustomerService')) : 1
			this.turnId = op.id
			this.loadDictData()
			this.showOrderDetail(op.id);
			this.id = op.id
			this.getStatusData()
			// 是否广州银行用户
			this.getIsGzyh()
			// 获取再来一单配置
			this.loadConf()
		},
		onPageScroll(e) {
					//兼容iOS端下拉时顶部漂移
					this.listScrollTop = e.scrollTop
					this.showToTop = this.listScrollTop > 0 ? true : false
				},
		computed: {
			reasonShow() {
				return this.statusData[this.order.status] +'原因'
			},
		},
		methods: {
			// 计算折扣信息
			// 数据结构 discountList:[activity:activity,rule:'',goodsList:[],total,discount]
			loadDiscount(){
				this.supplierDiscountTotal = 0
				// 参加营销活动的商品 type: 0-拼团(不展示店铺优惠) 1-多件折扣 3-N元任选
				const activityProducts = this.order.items.filter(item=>item.activity&&item.activity.data&&item.activity.data.type)
				if(activityProducts.length===0) return
				// 多件折扣
				// 多件折扣活动商品 type==1&&优惠金额
				const discountProducts = activityProducts.filter(p=>p.activity.data.type===1&&p.price<p.originalPrice)
				if(discountProducts.length>0){
					const discountAct = [...new Set(discountProducts.map(p=>p.activityId))]
					discountAct.forEach(actId=>{
						const temp = discountProducts.filter(p=>p.activityId === actId)
						console.log(temp)
						const activity = temp[0].activity
						let total,discount,totalNum = 0
						if(temp.length>1){
							total = temp.reduce((a,b)=> a.addFloat(b.originalPrice.multipleFloat(b.num)),0)
							discount = temp.reduce((a,b)=> a.addFloat((b.originalPrice.subtractFloat(b.price)).multipleFloat(b.num)),0)
							totalNum = temp.reduce((a,b)=> a+b.num,0)
						}else{
							totalNum = temp[0].num
							total = temp[0].originalPrice.multipleFloat(totalNum)
							discount = (temp[0].originalPrice.subtractFloat(temp[0].price)).multipleFloat(totalNum)
						}
						let rule = activity.ruleList.filter(r=>totalNum>=r.num)
						if(rule.length>0){
							rule = rule.sort((a,b)=>b.num-a.num)
						}
						this.supplierDiscountTotal = this.supplierDiscountTotal.addFloat(discount)
						this.discountList.push({activity:activity.data,rule:rule[0].num+'件'+rule[0].discount+'折',goodsList:temp,total:total,discount:discount})
					})
				}



			},
			clickShowDiscount(){
				if(this.supplierDiscountTotal > 0){
					this.showDiscount = !this.showDiscount
				}
			},
			getDiscount(product) {
				return product.originalPrice.subtractFloat(product.price)
			},
			toTop() {
							this.listScrollTop = 0;
							this.showToTop = false
							uni.pageScrollTo({
												scrollTop: this.listScrollTop,
												duration: 300
											});

						},
			makePhoneCall(phone){
				uni.makePhoneCall({
					phoneNumber: phone
				});
			},
			getSupplierCustomerGroup(ids){
				const param = ids.map(i=>{
					const str = 'supplierIds[]='+i
					return str
				 })
				listCustomerGroupBySupplierId({},param.join('&')).then(res=>{
					if(res.code===0){
						this.supplierCustomerGroup = res.data
					}
				})
			},
			toOnlineService(){
				const order = this.order
				let content = `订单编号:${order.sn}\n供应商订单号:${order.thirdSn}\n订单总额:${order.total}\n订单内商品:`+order.items.map(item =>item.productName).join('、')
				onlineService({ "type": "order", "content": content,"vendorId": this.supplierCustomerGroup[this.supplierData.id]}).then(res=>{
					if(res.code === 0){
						window.location.href=res.data
					}
				})
			},
			showSupplier(){
				this.supplierShow = !this.supplierShow
			},
			// 获取再来一单配置
			loadConf(){
				const deptInfo = uni.getStorageSync('deptinfo')[0]
				qryConfByItemCode({code:'enableOneMoreOrder',
				tenant_id: deptInfo.tenantId,
				dept_code: deptInfo.deptCode}).then(res=>{
					if(res.code===0){
						this.enableOneMoreOrder = res.data.val == '1'
					}
				})
			},
			// 是否广州银行用户
			getIsGzyh(){
				const deptInfo = uni.getStorageSync('deptinfo')[0]
				qryConfByItemCode({code: "isGzyhUser",
					tenant_id: deptInfo.tenantId,
					dept_code: deptInfo.deptCode}).then(res=>{
						if(res.code===0){
							this.isGzyhUser = res.data.val == '1'
						}
				})
			},
			returnIndex() {
				goback()
			},
		// tab页切换函数
			onTabsChange(index){
				this.logTabIndex = index
			},
			changeLogTab(e){
        	this.logTabIndex = e.target.current
			this.current = e.target.current
			},
			beforeConfirm(item){
				uni.showLoading({
					title:'加载中'
				})
				const param = {
					id: item.id
				}
				getLogistics(param).then(res => {
					uni.hideLoading()
					if (res.code === 0){
						this.logisticsList = res.data;
						this.logisticsTab = []
						this.logisticsList.forEach((item,index)=>{
							this.logisticsTab.push({name:'物流'+(index+1)})
						})
						if (this.logisticsList.length === 1 && item.status === 'shipped'){
						  this.clickConfirm(this.logisticsList[0])
						}else {
							this.receivePopupShow = true
						}
					}
				})
			},
			getBudgetsList(id) {
				console.log(id)
				getBudgets({
					id: id
				}).then(res => {
					console.log((res))
					this.budgetList = res.data.budgetData.budgetList
					this.budgetList.forEach(item=>{
						this.budgetShow.push(false)
					})
					console.log(res)
				})
			},
			turnIcon(val){
				// if(val ==)
			},
			//再来一单
			addToCart(item){
				uni.showLoading({
					title: '请稍后'
				})
				const params = {
					sn:this.turnId
				}
				buyAgain(params).then(res=>{
					if(res.code===0){
						uni.hideLoading();
						uni.switchTab({
							url:'/pages/cart/cart'
						})
					}else{
						uni.hideLoading();
					}
				})
			},
			//控制商品盒子的显示隐藏
			isShowGood(){
				this.canHide = !this.canHide
			},
			//控制发票详情展示显示隐藏
			isBillShow(){
				this.billShow = !this.billShow
			},
			//控制订单信息的显示隐藏
			isOrderShow(){
				this.orderShow = !this.orderShow
			},
			//控制预算信息的显示隐藏
			isBudgetShow(index){
				this.$set(this.budgetShow,index,!this.budgetShow[index])
			},
			goDetailWuLiu(){
				console.log('点击物流跳转');
				uni.navigateTo({
					// url: "/pages/order/logistics"
					url: '/pages/deliver/deliverLogistic?item='+this.order.id
				})
			},
			showReason(){
				// this.$util.msg('加入购物车成功')
				// uni.showToast({
				// 	 title: 'content',
				// 	 duration: 3000,
				// 	 mask:false,
				// 	 icon:'none'
				// });
				this.$refs.showReason.open()
			},
			cancelReason(){
				this.$refs.showReason.close()
			},
			returnIndex() {
				// uni.navigateBack();
				goback()
			},
			loadDictData() {
				const param = {
					data: '["DELIVERY_TYPE"]'
				}
				getDict(param).then(res => {
					if (res.code === 0) {
						let data = res.data.DELIVERY_TYPE
						data.forEach(item => {
							this.dictData[item.code] = item.name;
						})
					} else {
						this.$util.msg(res.message)
					}
				})
			},
      getLogList(){
        const param = {
          orderSn: this.order.sn
        }
        getLogList(param).then(res => {
          if (res.code === 0) {
            this.logData = res.data
          } else {
            this.$util.msg(res.message)
          }
        })
      },
			getStatusData() {
				getAllStatus().then(res => {
					if (res.code === 0) {
						this.statusData = res.data
					}
				})
			},
			loadLogistics() {
				getLogistics({
					id: this.order.id
				}).then(res => {
					if (res.code === 0) {
						this.logisticsList = res.data
						this.current = 0
						this.logTabIndex = 0
						this.logisticsTab = []
						this.logisticsList.forEach((item,index)=>{
							this.logisticsTab.push({name:'物流'+(index+1)})
						})
						// if (this.logisticsList.length === 1 && item.status === 'shipped'){
						//   this.clickConfirm(this.logisticsList[0])
						// }else {
						// 	this.receivePopupShow = true
						// }
					}
				})
			},
			loadCancelLog() {
				getOrderLogs({
					orderId: this.order.id
				}).then(res => {
					this.orderCancelLog = res.data.filter((t) => t.type === "cancelled" && t.remark)[0];
				})
			},
			loadCommitFailLog() {
				getOrderLogs({
					orderId: this.order.id
				}).then(res => {
					this.orderFailLog = res.data.filter((t) => t.type === "commitFail" && t.remark)[0];
				})
			},
			loadLogs(){
				queryOrderLogsInfo({orderId: this.order.id}).then(res=>{
					if(res.code===0){
						console.log(res)
						this.cancelApplyInfo = res.extra.cancelApplyInfo||{}
						if(this.cancelApplyInfo.curStatus == 1){
							this.getCountDown(this.cancelApplyInfo.applyTime)
						}
					}
				})
			},
			getCountDown(start){
				if(!start) start = moment().format('YYYY-MM-DD HH:mm:ss')
				const end = moment(start).add(1,'days').format('YYYY-MM-DD HH:mm:ss')
				const result = moment(end).diff(moment(),'seconds',false)
				this.countDown = result>0?result:0
			},
			showOrderDetail(id) {
				getOrderDetail({
					sn: id
				}).then(res => {
					if (res.code == 0) {
						let datas = res.data
						this.order = datas;
						this.getLogList()
						this.supplierData = this.order.supplier
						this.getSupplierCustomerGroup([this.supplierData.id])
						console.log('this.order',this.order);
						//支付总额
						this.summary.freight = datas.freight
						// datas.preferentialFee = 0;
						datas.items.forEach(item => {
							this.summary.num += item.num
							this.summary.totalPrice += item.salePrice * item.num
							if (item.salePrice < item.marketPrice) {
								this.summary.amountDesc += (item.marketPrice - item.salePrice) * item.num;
							}
						})
						this.summary.amount = this.summary.totalPrice + this.summary.freight
						if (datas.protocolType === 'eplus') {
							this.summary.amount = this.summary.amount + datas.serviceFee - datas.preferentialFee
						}
						if (this.order.status === 'cancelled' || this.order.status === 'refuse') {
							this.loadCancelLog()
						} else if (this.order.status === 'commitFail') {
							this.loadCommitFailLog()
						}
						if(this.order.isOpenBudget === true) {
							this.getBudgetsList(this.order.id)
						}
						this.loadLogistics()
						this.loadLogs()
						this.loadDiscount()
					} else {
						this.$util.msg(res.message)
					}
				})
			},
			clickAfterSale(item) {
				let sn = this.order.sn
				let id = item.id
				let deptName = this.order.deptName
				const params = {
					orderItemId: id,
					orderSn: sn,
					type: 1
				}
				applyAftersale(params).then(res => {
					if (res.code === 0) {
						if (res.data) {
							uni.navigateTo({
								url: `/pages/aftersale/aftersale?sn=${sn}&id=${id}&deptName=${deptName}&type=1`,
							})
						} else {
							this.$util.msg('没有可以发起售后申请商品的数量')
						}
					} else {
						this.$util.msg(res.message)
					}
				})
			},
			goProductDetail(id) {
				uni.navigateTo({
					url: `/pages/product/product?id=${id}`
				})
			},
			// 确认收货
			clickConfirm(item) {
				const that = this
				uni.showModal({
					title: '提示',
					content: '请确认是否已收到货？',
					confirmColor: that.themeColor,
					success: suc => {
						if (suc.confirm) {
							confirmReceipt({
								id: that.order.id,
								outgoingSn: item.outgoingSn
							}).then(res => {
								if (res.code === 0) {
									that.$util.msg('确认收货成功!')
									that.showOrderDetail(that.id)
								} else {
									that.$util.msg(res.message)
								}
							})
						}
					}
				})
			},
		}
	}
</script>

<style lang="scss">
	.container {
		background-color: $my-bg-color-grey;

		.wordClass {
			font-family: PingFangSC-Medium;
		}
	.budget-title{
			text-align: center;
			font-weight: bold;
			font-size: 16px;
			color: #333;
			padding: 15px;
			border-bottom: 1px solid #e9e9e9;
		}
		.my-navbar {
			display: flex;
			align-items: center;
			justify-content: center;
			position: relative;
			width: 100%;
			height: 88rpx;
			padding: 0 30rpx;
			font-size: $my-font-size-lg;
			border-bottom: 1px solid $my-border-color;
			background-color: $my-bg-color;
			position: fixed;
			left: 0;
			top: calc(var(--window-top) + var(--status-bar-height));
			z-index: 10;
			background: $my-bg-color;

			image {
				position: absolute;
				left: 30rpx;
				width: 28rpx;
				height: 40rpx;
			}
		}

		.content {
			// padding-top: 16rpx;
			font-size: $my-font-size-sm;

			.head-section {
				display: flex;
				flex-direction: column;
				height: 336rpx;
				position: relative;
				background-image: url(../../static/newh5/bg.png);
				background-position: absolute;
				background-repeat: no-repeat;
				background-size: 100% auto;
				background-position: 10 100%;

				.bg {
					position: absolute;
					left: 0;
					top: 0;
					// z-index: 999;
					width: 100%;
					height: 100%;
				}

				.wuliu {
					width: 100%;
					height: 80rpx;
					color: #EEEEEE;
					font-family: PingFangSC-Medium;
					font-size: 18px;
					display: flex;
					justify-content: space-between;
					align-items: center;
					.contentBox{
						display: flex;
						justify-content: center;
						flex: 1;
					}
					.contentBoxCenter{
						display: flex;
						justify-content: center;
						flex: 2;
					}
					.reasonButton{
						// flex: 1;
						// margin-left: 300rpx;
						// margin-: auto;
						width: 130rpx;
						height: 55rpx;
						line-height: 55rpx;
						text-align: center;
						// padding-left: 15rpx;
						border: 1px solid #EEEEEE;
						border-radius: 15rpx;
						font-size: 24rpx;
					}
				}
			}

			.yticon {
				font-size: 44upx;
				color: #5eba8f;
				margin-right: 16upx;
				line-height: 40upx;
			}

			.line {
				display: flex;
				align-items: center;
				height: 76rpx;
				border-bottom: 1px solid $my-border-color-grey;
				padding: 0 30rpx;
				background-color: $my-bg-color;

				&.remark {
					word-break: break-all;
					height: auto;
					padding: 30rpx;
					display: flex;

					.left {
						display: flex;
						align-items: center;
						width: 16%;
					}

					.right {
						width: 84%;
					}
				}

				&>.detail {
					color: $my-text-color-active;
				}

				.status {
					margin: auto;
					margin-right: 0;
					color: $my-bg-color-red;
				}
			}

			.cgr-info {
				display: flex;
				flex-direction: row;
				// margin:0 auto;
				// z-index: 999;
				background: #EEEEEE;
				padding: 20rpx 30rpx;
				width: 92%;
				min-height: 150rpx;
				line-height: 55rpx;
				margin: 16rpx 0;
				margin-left: 8rpx;
				border-top: 1px solid #e2e2e2;
				border-bottom: 1px solid #e2e2e2;
				background-color: $my-bg-color;
				border-radius: 15rpx;

				.cgr-icon{
					margin-left: 0;
					margin-right: 10rpx;
				}

				.tel {
					margin-left: 30rpx;
				}

				.address {
					line-height: 18px;
					color: $my-text-color-grey;
				}
			}

			.logistics {
				width: 100%;
				margin: 16rpx 0;
				font-size: 13px;

				.item {
					background-color: #fff;
					width: 100%;
					padding: 16rpx 40rpx;
					display: flex;
					flex-direction: column;
					border-bottom: 1px solid #e2e2e2;

					.btn {
						width: 160upx;
						height: 60upx;
						margin: 0;
						padding: 0;
						text-align: center;
						line-height: 60upx;
						font-size: $font-sm + 2upx;
						background: #fff9f9;
						color: $base-color;
						border-radius: 10px;
						// border-color: $base-color;
						border: 0.5px solid $base-color;
						// border-color: #f7bcc8;
					}

					.c-line {
						padding: 10rpx 0;
					}

					.p-line {
						padding: 10rpx 0;
						display: flex;
						justify-content: flex-start;
						// align-items: center;

						.left-side {
							width: 70px;
							font-size: 13px;
						}

						.right-side {
							flex: 1;
							display: flex;
							flex-direction: column;

							.right-item {
								padding-bottom: 10rpx;
							}
						}

						.track-list {
							flex:1;
							padding: 10rpx 0;

							.track-item {
								.time {}

								.day {}

								.content {}
							}
						}
					}

					.detail {}
				}
			}

			.product-list {
				// padding: 10rpx;
				// border-top: 1px solid $my-border-color-grey;
				// border-bottom: 1px solid $my-border-color-grey;
				.showHide{
					display: flex;
					background-color: $my-bg-color;
					justify-content: center;
				}
				.item {
					display: flex;
					border-bottom: 1px solid #e2e2e2;
					background-color: $my-bg-color;
					padding: 10rpx 20rpx;

					&:last-child {
						border-bottom: none;
					}

					.left {
						width: 200rpx;
						height: 200rpx;
						margin-right: 20rpx;

						image {
							width: 100%;
							height: 100%;
						}
					}

					.right {
						flex: 1;
						// width: 550rpx;
						display: flex;
						// justify-content: space-between;
						flex-direction: column;

						.name {
							text-overflow: ellipsis;
							display: -webkit-box;
							-webkit-box-orient: vertical;
							-webkit-line-clamp: 2;
							overflow: hidden;
							line-height: 40rpx;
							height: 80rpx;
							word-break: break-all;
						}

						.bottom {
							display: flex;
							margin-top: 14rpx;

							.price {
								display: flex;
								flex-direction: column;
								// color: $my-text-color-red;
								line-height: 32rpx;
							}

							.num {
								margin: auto;
								margin-right: 0;
								margin-top: 0;
							}
						}

						.action {
							margin-top: 14rpx;
							width: fit-content;
							height: fit-content;
							padding: 4rpx 16rpx;
							text-align: center;
							font-size: 12px;
							color: $font-color-dark;
							background: #fff;
							border-radius: 15px;
							border: 0.5px solid #C0C4CC;
						}
					}
				}
			}
			.total {
				// height: 300rpx;
				margin-top: 16rpx;
				padding: 20rpx 30rpx;
				background-color: $my-bg-color;
				.total-l {
					height: 52rpx;
					display: flex;
					align-items: center;
					.l-word{
						font-family: PingFangSC-Regular;
						color: #646464;
					}
					.l-p {
						margin: auto;
						margin-right: 0;
						// color: $my-text-color-red;

					}
				}
				.hideButton{
					height: 52rpx;
					display: flex;
					align-items: center;
					justify-content: center;
					color: #909090;

					.innerBox{
						width: 100rpx;
						text-align: center;
						border-radius: 15rpx;
						border: 1rpx solid #909090;
					}
				}
				.invoiceBox{
					.title{
						display: flex;
						justify-content: space-between;
						padding-bottom: 20rpx;
						font-size: $my-font-size-sm;
					}
				}
				.time {
					width: 100%;
					text-align: left;
					color: $my-text-color-grey;
				}
			}
			.plusBuy{
				height: 100rpx;
				margin-top: 16rpx;
				padding: 20rpx 30rpx;
				background-color: $my-bg-color;
				display: flex;
				flex-direction: row-reverse;
				.plusButton{
					width: 130rpx;
					height: 65rpx;
					padding-left: 15rpx;
					border: 1px solid #FF4D4F;
					color: #FF4D4F;
					border-radius: 8px;
					.buttonWord{
						color: #FF4D4F;
						line-height: 65rpx;
					}
				}
				.primaryButton{
					margin-right: 20rpx;
					width: 130rpx;
					height: 65rpx;
					padding-left: 15rpx;
					border: 1px solid $border-color-dark;
					border-radius: 8px;
					.buttonWord{
						color: black;
						line-height: 65rpx;
					}
				}
			}
		}
	}
		.top-back {
			width: 80rpx;
			height: 80rpx;
			position: fixed;
			right: 34rpx;
			bottom: 200rpx;
			-webkit-overflow-scroll: touch;
			z-index: 100000;
		}

</style>
